package com.java.singletonpattern;

/**
 * @author luzhikun
 * @date 2020/12/9-21:29
 * <p>
 * 饿汉式
 */
public class TheHungryType {
    public static void main(String[] args) {
        Hungry hungry1 = Hungry.getInstance();
        Hungry hungry2 = Hungry.getInstance();
        System.out.println(hungry1);
        System.out.println(hungry2);
    }
}

class Hungry {
    private Hungry() {
    }

    private static Hungry hungry = new Hungry();

    public static Hungry getInstance() {
        return hungry;
    }
}